package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i("**MyDebug**", "onCreate");
        //隐式意图
        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
//                Intent intent = new Intent(Intent.ACTION_DIAL);
//                Uri data = Uri.parse("tel:18770554599");
                Intent intent=new Intent(Intent.ACTION_VIEW);
                Uri data=Uri.parse("http://baidu.com");
                intent.setData(data);
                startActivity(intent);
            }
        });
    }

    public void sendMessage(View view) {
        //定义意图：显示意图
        Intent intent = new Intent(this, MainActivity2.class);

        EditText editText = findViewById(R.id.editTextTextPersonName);
        String message = editText.getText().toString();

        intent.putExtra("Message", message);
        startActivity(intent);
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.i("**MyDebug**", "onStart");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.i("**MyDebug**", "onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i("**MyDebug**", "onDestroy");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.i("**MyDebug**", "onPause");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.i("**MyDebug**", "onResume");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.i("**MyDebug**", "onRestart");
    }
}